#ifndef AST_DECLARATIONS_DECLARATION_SPECIFIERS_H
#define AST_DECLARATIONS_DECLARATION_SPECIFIERS_H

#include "../ASTNode.h"
class StorageClassSpecifier;
class TypeSpecifier;
class TypeQualifier;
class FunctionSpecifier;

/*
C99  6.7
declaration-specifiers:
			storage-class-specifier    declaration-specifiers(opt)
			type-specifier    declaration-specifiers(opt)
			type-qualifier    declaration-specifiers(opt)
			function-specifier    declaration-specifiers(opt)
*/
class DeclarationSpecifiers : public ASTNode
{
public:
	enum {
		storage_class_specifier,
		type_specifier,
		type_qualifier,
		function_specifier
	};
protected:
	DeclarationSpecifiers(void)
		: ASTNode(ASTNode::declaration_specifiers){};
public:
	DeclarationSpecifiers(StorageClassSpecifier *pStorage, DeclarationSpecifiers *pSpecs = NULL)
		: ASTNode(ASTNode::declaration_specifiers)
		, m_iType(storage_class_specifier)
		, m_pStorageSpecs(pStorage)
		, m_pDeclarationSpecs(pSpecs){};
	DeclarationSpecifiers(TypeSpecifier *pTypeSpec, DeclarationSpecifiers *pSpecs = NULL)
		: ASTNode(ASTNode::declaration_specifiers)
		, m_iType(type_specifier)
		, m_pDeclarationSpecs(pSpecs)
		, m_pTypeSpecs(pTypeSpec) {};
	DeclarationSpecifiers(TypeQualifier *pTypeQuals, DeclarationSpecifiers *pSpecs = NULL)
		: ASTNode(ASTNode::declaration_specifiers)
		, m_iType(type_qualifier)
		, m_pDeclarationSpecs(pSpecs)
		, m_pTypeQuals(pTypeQuals) {};
	DeclarationSpecifiers(FunctionSpecifier * pFuncSpec, DeclarationSpecifiers *pSpecs = NULL)
		: ASTNode(ASTNode::declaration_specifiers)
		, m_iType(function_specifier)
		, m_pDeclarationSpecs(pSpecs)
		, m_pFuncSpecs(pFuncSpec) {};

	virtual ~DeclarationSpecifiers(void);

	virtual void									codeGen();

protected:
	DeclarationSpecifiers *							m_pDeclarationSpecs;
	tiny_int										m_iType;
	union{
		StorageClassSpecifier *						m_pStorageSpecs;
		TypeSpecifier	*							m_pTypeSpecs;
		TypeQualifier *								m_pTypeQuals;
		FunctionSpecifier *							m_pFuncSpecs;
	};
};
#endif

